<?php
function getSupplierName($supplier_idx){
    $supplierName   =   S('supplier_name_'.$supplier_idx);
    if($supplierName){
        return $supplierName;
    } else {
        $supplierName   =   D('Supplier')->where(array('idx'=>array('eq',$supplier_idx)))->getField('name');
        S('supplier_name_'.$supplier_idx,$supplierName,300*60*60);
        return $supplierName;
    }
    
}

//清除数组中的空值
function clearArrayNull($val){
    if($val != ''){
        return true;
    }
}

/*
 * 生成交易流水号
 * @param char(2) $type
 */
function doOrderSn($type)
{
    $time = time();
    $st   = rand(10, 99);
    $A    = date('Y', $time);
    $B    = date('m', $time);
    $C    = date('d', $time);
    $D    = date('H', $time);
    $E    = date('i', $time);
    $F    = date('s', $time);
    $G    = $type;
    $H    = $st;
    $CC   = ($A % 15 * 3 + $B % 7 * 2 + $C % 7 * 5 + $D % 9 * 7 + $E % 9 * 5 + $F % 9 * 6 + $G % 3 * 3 + $H % 23 * 7) % 100;
    if ($CC < 10) {
        $res = $A . $B . $C . $D . $E . $F . $G . $H . '4' . $CC;
    } else {
        $res = $A . $B . $C . $D . $E . $F . $G . $H . $CC;
    }

    return $res;
}